import java.util.*;

/**
 * @author LKQ
 * @date 2022/4/6 15:26
 * @description 求和 + 求模，但是要注意求和会溢出问题
 */
public class Solution {
    public static void main(String[] args) {

    }
    public int chalkReplacer(int[] chalk, int k) {
        // 10 ^ 10 = 1.0E10 2 ^ 31 = 2.1474E9, int 保存和会出现溢出问题
        long sum = 0;
        for(int i: chalk) {
            sum += i;
        }
        long res = k % sum;
        for(int i = 0; i < chalk.length; i++) {
            if(res < chalk[i]) {
                return i;
            }
            res -= chalk[i];
        }
        return 0;
    }
}
